#include<iostream>
using namespace std;
const int N = 1e4 + 10;
int p[N];
int f[N];
int v[N], w[N];
int n, m, vol;
int find(int x)
{
	if (x != p[x]) {
		p[x] = find(p[x]);
	}
	return p[x];
}
int main()
{
	cin >> n >> m >> vol;
	for (int i = 1; i < N; i++) {
		p[i] = i;
	}
	for (int i = 1; i <= n; i++) {
		cin >> v[i] >> w[i];
	}
	while (m--) {
		int a, b;
		cin >> a >> b;
		a = find(a);
		b = find(b);
		if (a != b) {
			v[b] += v[a];
			w[b] += w[a];
			p[a] = b;
		}
	}
	for (int i = 1; i <= n; i++) {
		if (i == find(i)) {
			for (int j = vol; j >= v[i]; j--) {
				f[j] = max(f[j], f[j - v[i]] + w[i]);
			}
		}
	}
	cout << f[vol] << endl;
	return 0;
}